package com.xpqh.ksg.common.persistence.dao;

import com.xpqh.ksg.common.persistence.model.KsgBrandInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xpqh.ksg.common.persistence.model.KsgCaseInfo;
import com.xpqh.ksg.modular.core.dto.*;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 车辆品牌 Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2025-04-18
 */
public interface KsgBrandInfoMapper extends BaseMapper<KsgBrandInfo> {

    @Select("select  brand_name brandName,id brandId,icon_url iconUrl,Initial_first initialFirst from ksg_brand_info where state = 0 order by sort asc")
    List<KsgBrandListRespDTO> getBrandList();

    @Select("select Initial_first groupName from ksg_brand_info where state = 0  GROUP BY Initial_first ORDER BY Initial_first ASC")
    List<KsgBrandGroupListRespDTO> getBrandGroupList();


    @Update("update ksg_stock_info set store_id = #{storeId},office_code = #{storeId},distribute_type = 1,distribute_time = now() where signal_id = #{signalId}")
    Integer updateStockInfo(@Param("storeId") String storeId, @Param("signalId") String signalId);
    @Insert("insert into ksg_stock_log (signal_id,store_id,create_time)" +
            "values (#{signalId},#{storeId},now())")
    Integer insertStockLog(@Param("storeId") String storeId,@Param("signalId") String signalId);
    @Insert("insert into ksg_stock_record (signal_id,store_id,create_time,user_code,operation_type)" +
            "values (#{signalId},#{storeId},now(),#{userId},'分发')")
    Integer insertStockRecord(@Param("storeId") String storeId,@Param("signalId") String signalId,@Param("userId") Integer userId);


    @Insert("insert into ksg_after_sales(phone,note,picture,create_time)" +
            "values(#{phone},#{note},#{picture},now())")
    Integer afterSales(@Param("phone") String phone,@Param("note") String note,@Param("picture") String picture);

    @Select("select picture,url from ksg_banner_info where is_delete = 0 and is_home_page = 0 and language = #{language} order by create_time desc")
    List<KsgBannerListReqDTO> getBannerList(@Param("language") String language);

    @Select("select country,mobile_prefix mobilePrefix from country_mobile_prefix ")
    List<KsgCountryListRespDTO> getCountryList();

    List<KsgCaseInfo> getCaseListByHomeByPc(@Param("language") String language);

    @Select("          SELECT office_code storeId,office_name storeName,phone storePhone,address storeAddress, " +
            "          zip_code longitude,email latitude,leader businessRange " +
            "          from js_sys_office a WHERE status = 0  LIMIT 0,8")
    List<KsgStoreInfoListRespDTO> getStoreInfoList2ByHome();

    List<KsgNewsListRespDTO> getNewsListByHome();
}


